let ajaxCount = 0
export default (params) => {
  ajaxCount++
  wx.showLoading({ title: '加载中...' })
  return new Promise((resolve, reject) => {
    wx.request({
      ...params,
      url: `https://api-hmugo-web.itheima.net/api/public/v1${params.url}`,
      success: (res) => {
        resolve(res.data.message)
      },
      fail: reject,
      complete: () => {
        ajaxCount--
        if (ajaxCount === 0) wx.hideLoading()
      }
    })
  })
}
